package com.platform.mobile.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.platform.common.dao.impl.CommonDaoImpl;
import com.platform.mobile.dao.MainPageDao;
import com.platform.mobile.entity.VisitNotice;
import com.platform.tool.HelpFunctions;

@Repository
public class MainPageDaoImpl extends CommonDaoImpl 
			implements MainPageDao{

	@SuppressWarnings("unchecked")
	@Override
	public VisitNotice getNoticeByOrgId(String org_id) {
		
		List<VisitNotice> list = new ArrayList<VisitNotice>();
		
		StringBuilder whereSql = new StringBuilder("from VisitNotice where 1=1 ");
		List<String> params = new ArrayList<String>();
		
		whereSql.append("and h_id = ? ");
		params.add(org_id);
		
		whereSql.append("and create_time = (select MAX(create_time) from VisitNotice where h_id = ?)");
		params.add(org_id);
		
		list = (List<VisitNotice>) getListByHQL(whereSql.toString(),params.toArray(),
				null);
		
		if(!HelpFunctions.isEmpty(list)){
			return list.get(0);
		} else {
			return null;
		}
	}

}
